import { Suspense, lazy } from 'react';
import { Navigate, Outlet } from 'react-router-dom';

import { SvgIcon } from '@/components/icon';
import { CircleLoading } from '@/components/Loading';

import { AppRouteObject } from '#/router';

const ListPage = lazy(() => import('@/pages/admin/order'));
const AccountPage = lazy(() => import('@/pages/admin/account'));
const AddressPage = lazy(() => import('@/pages/admin/address'));
const PicturePage = lazy(() => import('@/pages/admin/picture'));
const WalletPage = lazy(() => import('@/pages/admin/wallet'));
const WithdrawPage = lazy(() => import('@/pages/admin/withdraw'));
const UpgradePage = lazy(() => import('@/pages/admin/upgrade'));
const CollectPage = lazy(() => import('@/pages/admin/collect'));
const DesignPage = lazy(() => import('@/pages/admin/design'));
const CouponPage = lazy(() => import('@/pages/admin/coupon'));
const RecommendPage = lazy(() => import('@/pages/admin/recommend'));
const MessagePage = lazy(() => import('@/pages/admin/message'));
const CartPage = lazy(() => import('@/pages/admin/cart'));
const RechargePage = lazy(() => import('@/pages/admin/recharge'));
const admin: AppRouteObject = {
  order: 2,
  path: 'admin',
  element: (
    <Suspense fallback={<CircleLoading />}>
      <Outlet />
    </Suspense>
  ),
  meta: {
    label: '会员中心',
    icon: <SvgIcon icon="ic-management" className="ant-menu-item-icon" size="24" />,
    key: '/admin',
  },
  children: [
    {
      index: true,
      element: <Navigate to="order" replace />,
    },
    {
      path: 'cart',
      element: <CartPage />,
      meta: { label: '购物车', key: '/admin/cart' },
    },
    {
      path: 'order',
      element: <ListPage />,
      meta: { label: '我的订单', key: '/admin/order' },
    },
    {
      path: 'design',
      element: <DesignPage />,
      meta: { label: '我的设计', key: '/admin/design' },
    },
    {
      path: 'collect',
      element: <CollectPage />,
      meta: { label: '我的收藏', key: '/admin/collect' },
    },
    {
      path: 'picture',
      element: <PicturePage />,
      meta: { label: '我的图库', key: '/admin/picture' },
    },
    {
      path: 'recommend',
      element: <RecommendPage />,
      meta: { label: '推广中心', key: '/admin/recommend' },
    },
    {
      path: 'wallet',
      element: <WalletPage />,
      meta: { label: '我的钱包', key: '/admin/wallet' },
    },
    // {
    //   path: 'recharge',
    //   element: <RechargePage />,
    //   meta: { label: '我的充值', key: '/admin/recharge' },
    // },
    // {
    //   path: 'withdraw',
    //   element: <WithdrawPage />,
    //   meta: { label: '我的提现', key: '/admin/withdraw' },
    // },
    {
      path: 'coupon',
      element: <CouponPage />,
      meta: { label: '优惠券', key: '/admin/coupon' },
    },
    {
      path: 'upgrade',
      element: <UpgradePage />,
      meta: { label: '企业定制、品牌/IP商务合作', key: '/admin/upgrade' },
    },
    {
      path: 'account',
      element: <AccountPage />,
      meta: { label: '个人信息', key: '/admin/account' },
    },
    {
      path: 'address',
      element: <AddressPage />,
      meta: { label: '地址管理', key: '/admin/address' },
    },
    {
      path: 'message',
      element: <MessagePage />,
      meta: { label: '消息通知', key: '/admin/message' },
    },
  ],
};

export default admin;
